package com.icxcc.icxoauth.service.impl;

import com.icxcc.icxoauth.provider.MyClientDetails;
import com.icxcc.icxoauth.service.SysClientService;
import org.springframework.context.annotation.Primary;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.stereotype.Service;

@Primary
@Service("sysClientService")
public class SysClientServiceImpl implements SysClientService {

    @Override
    public ClientDetails loadClientByClientId(String clientId) {
        PasswordEncoder passwordEncoder=new BCryptPasswordEncoder(4);
        MyClientDetails clientDetails = new MyClientDetails();
        clientDetails.setClientId("icxcc-1");
        clientDetails.setScope("read");
        clientDetails.setClientSecret(passwordEncoder.encode("icxcc"));
        clientDetails.setAuthorizedGrantTypes("refresh_token,password,authorization_code,client_credentials");
        return clientDetails;
    }
}

